function draw_npcs(map)

	for i = 1, tablelength(map.npcs) do
		draw_in_fov(map.npcs[i])
	end

end

function place_npcs(npcs)

		NPC = { x = 10*tile_size, y = 22*tile_size,
			turn=false, health=1000, image=mayor_img,
			visible = true, alive = true,
			damage = 1000, name = "mayor",
			type = "npc", print_health = false,
			inventory = {}, shopping = false, shop_id = 1,
			price_mod = 4, q_given = false}
		table.insert(npcs,NPC)

		NPC = { x = 6*tile_size, y = 4*tile_size,
			turn=false, health=1000, image=botanist_img,
			visible = true, alive = true,
			damage = 1000, name = "botanist",
			type = "npc", print_health = false,
			inventory = {}, shopping = false, shop_id = 2,
			price_mod = 4, q_given = false}
		table.insert(npcs,NPC)

		NPC = { x = 24*tile_size, y = 26*tile_size,
			turn=false, health=1000, image=human_f_img,
			visible = true, alive = true,
			damage = 1000, name = "woman",
			type = "npc", print_health = false,
			inventory = {}, shopping = false, shop_id = 3,
			price_mod = 4, q_given = false}
		table.insert(npcs,NPC)

		NPC = { x = 15*tile_size, y = 15*tile_size,
			turn=false, health=1000, image=nurse_img,
			visible = true, alive = true,
			damage = 1000, name = "nurse",
			type = "npc", print_health = false,
			inventory = {}, shopping = false, shop_id = 4,
			price_mod = 4, q_given = false }
		table.insert(npcs,NPC)

		--print(table.tostring(maps.town.npcs))

end

function itemize_npcs(npcs)

	for i = 1, #npcs do

		give_item(Apple, npcs[i])
		print("Gave ",npcs[i].name, " an Apple")

	end


end

function npc_range (x, y, npc)

	distX = npc.x - x
	distY = npc.y - y

	absDistX = math.abs(distX)
	absDistY = math.abs(distY)

	return absDistX, absDistY


end

function npc_check_fov(x, y, npc, npc_fov)

	distX, distY = npc_range(x,y, npc)

	if distX <= npc_fov*tile_size
		and distY <= npc_fov*tile_size then
		return true
	else
		return false
	end


end

function npc_town_ai(npc)




end

function npc_veggie_quest(npc)

	if npc.name ~= "mayor" then
		npc.vq = veggie_selector()
		local qs = "You've been sent on a quest for a "
		local ss = append_strings(qs, npc.vq)
		printc(ss)

		p_accept_quest(npc)
	else

	end


end

function npc_show_inv(npc)

	if #npc.inventory ~= nil then
		print("npc price mod : ", npc.price_mod)
		trade_window(trade_win, npc.inventory, npc.price_mod)
	end


end

function npc_tidy(npcs)
	for i = 1, #npcs do
		if npc_check_fov(npcs[i].x,npcs[i].y,
			npcs[i],npc_fov) == true then

		else
			npcs[i].shopping = false

		end

		if #npcs[i].inventory > 20 then

			for j = #npcs[i].inventory, 1, -1 do
				if j > 20 then

					table.remove(npcs[i].inventory, j)
				end
			end

		end

	end

end
